
class BinaryTree:
   def __init__(self, value, leftChild, rightChild):
      self.parent = None
      self.value = value
      self.leftChild = leftChild
      self.rightChild = rightChild
      if leftChild != None: leftChild.parent = self
      if rightChild != None: rightChild.parent = self

def find_elem_in_tree(tree, v, trackerFunc=lambda t:True):
   if tree == None:
      return None

   goOn = trackerFunc(tree)
   if tree.value == v:
      return tree
   if goOn:
      return find_elem_in_tree(
               tree.leftChild if v < tree.value else tree.rightChild, 
               v, trackerFunc)
   else:
      return None

   

class LinkedListNode:
   def __init__(self, value):
      self.value = value
      self.nextNode = None

   def __str__(self):
      return str(self.value)

def list_to_linked_list(thelist):
   head = LinkedListNode(thelist[0])
   node = head
   for n in range(1, len(thelist)):
      node.nextNode = LinkedListNode(thelist[n])
      node = node.nextNode
   return head

